import requestProxy from '@/utils/request';
const { request } = requestProxy;

// 获取供应商结算tab
export function getSupplierTab(params) {
  return request({
    url: '/admin/supplier/settle/tab',
    method: 'get',
    params
  });
}

// 获取供应商结算详情
export function getSupplierDetail(id, params = {}) {
  return request({
    url: `/admin/supplier/settle/${id}`,
    method: 'get',
    params
  });
}

// 获取成本列表
export function getSupplierCost(params) {
  return request({
    url: '/admin/supplier/cost/list',
    params
  });
}
// 获取供应商管理列表
export function supplierManageList(params) {
  return request({
    url: '/admin/supplier/manage/list',
    method: 'get',
    params,
    timeout: 9000
  });
}

// 获取供应商结算列表
export function getSupplierList(params, cancelToken) {
  return request({
    url: '/admin/supplier/settle/list',
    method: 'get',
    params: {
      notShowNoAuthTip: true,
      ...params
    },
    cancelToken
  });
}

// 供应商列表删除
export function supplierManageDelete(id) {
  return request({
    url: `admin/supplier/delete/${id}`,
    method: 'delete'
  });
}

// 发起结算
export function supplierLaunch(data) {
  return request({
    url: '/admin/supplier/launch',
    method: 'post',
    data
  });
}
// 提交结算
export function supplierSubmit(data) {
  return request({
    url: '/admin/supplier/submit',
    method: 'post',
    data
  });
}

export function supplierSettleOrder(data) {
  return request({
    url: '/admin/supplier/order/list',
    method: 'post',
    data
  });
}

// 结算进度【订单列表显示】
export function getOrderProcess(params) {
  return request({
    url: '/admin/supplier/process',
    method: 'get',
    params
  });
}

// 供应商名称是否重复
export function isRepeatSupplier(params) {
  return request({
    url: 'admin/supplier/isRepeat',
    method: 'get',
    params
  });
}

// 供应商备注修改
export function supplierRemark(id, data) {
  return request({
    url: `admin/supplier/remark/${id}`,
    method: 'put',
    data
  });
}
// 审批通过
export function supplierAuditPass(id) {
  return request({
    url: `/admin/supplier/auditPass/${id}`,
    method: 'put'
  });
}
// 审批未过审
export function supplierAuditRefuse(id, data) {
  return request({
    url: `/admin/supplier/auditRefuse/${id}`,
    method: 'put',
    data
  });
}

// 供应商新建
export function supplierAdd(data) {
  return request({
    url: 'admin/supplier/add',
    method: 'post',
    data
  });
}

// 供应商编辑
export function supplierEdit(id, data) {
  return request({
    url: `admin/supplier/edit/${id}`,
    method: 'put',
    data
  });
}

// 供应商删除
export function supplierDel(id) {
  return request({
    url: `admin/supplier/delete/${id}`,
    method: 'delete'
  });
}

// 供应商详情
export function supplierInfo(id, params = {}) {
  return request({
    url: `admin/supplier/manage/info/${id}`,
    method: 'get',
    params
  });
}
// 供应商账户列表
export function accountList(params) {
  return request({
    url: 'admin/accountsReceivable/list',
    method: 'get',
    params
  });
}
// 供应商账户列表编辑
export function accountAdd(data) {
  return request({
    url: 'admin/accountsReceivable/add',
    method: 'post',
    data
  });
}
// 供应商账户列表编辑
export function accountEdit(data) {
  return request({
    url: 'admin/accountsReceivable/edit',
    method: 'put',
    data
  });
}
// 供应商账户列表删除
export function accountDelete(id, data) {
  return request({
    url: `admin/accountsReceivable/delete/${id}`,
    method: 'delete',
    data
  });
}
// 供应商资源组列表详情
export function supplierResourceInfo(id) {
  return request({
    url: `admin/supplier/resourceList/${id}`,
    method: 'get'
  });
}

// 供应商关联资源删除
export function supplierResourceDel(id) {
  return request({
    url: `admin/supplier/resource/del/${id}`,
    method: 'delete'
  });
}

// 供应商关联资源选择
export function supplierResourceChoice(data) {
  return request({
    url: 'admin/supplier/resource/choice',
    method: 'get',
    data
  });
}

// 供应商创建关联组
export function supplierResourceCreate(data) {
  return request({
    url: 'admin/supplier/resourceGoup/add',
    method: 'get',
    data
  });
}

// 供应商规则备注修改
export function resourceRemarkEdit(id, data) {
  return request({
    url: `admin/supplier/rule/remark/${id}`,
    method: 'put',
    data
  });
}

// 供应商资源列表详情
export function resourceInfo(id) {
  return request({
    url: `admin/supplier/resourceList/${id}`,
    method: 'get'
  });
}

// 销售供应商-发起修改审批
export function supplierModify(data) {
  return request({
    url: 'admin/supplier/modify',
    method: 'post',
    data
  });
}

// 销售供应商-修改审批详情
export function supplierModifyDetail(id) {
  return request({
    url: `admin/supplier/modify/detail/${id}`,
    method: 'get'
  });
}

// 销售供应商-修改记录列表
export function recordInfo(id) {
  return request({
    url: `admin/supplier/recordList/${id}`,
    method: 'get'
  });
}

// 销售供应商-修改记录删除
export function supplierRecordDelete(id) {
  return request({
    url: `admin/supplier/record/delete/${id}`,
    method: 'delete'
  });
}

// 销售供应商-修改节点审批
export function supplierModifyAudit(data) {
  return request({
    url: 'admin/supplier/modify/audit',
    method: 'post',
    data
  });
}

// 销售供应商-修改详情评论列表
export function getSupplierModifyComments(params) {
  return request({
    url: '/admin/supplierModify/comments/list',
    method: 'get',
    params
  });
}

// 销售供应商-修改详情发表评论
export function supplierModifyCommentAdd(data) {
  return request({
    url: '/admin/supplierModify/comments/add',
    method: 'post',
    data
  });
}

// 创建资源组
export function resourceAdd(data) {
  return request({
    url: 'admin/supplier/resourceGoup/add',
    method: 'post',
    data
  });
}

// 资源组列表
export function resourceList(params, cancelToken) {
  return request({
    url: 'admin/supplier/resource/list',
    method: 'get',
    params,
    cancelToken
  });
}

// 资源组删除
export function resourceGroupDel(id) {
  return request({
    url: `admin/supplier/resourceGoup/del/${id}`,
    method: 'delete'
  });
}

// 资源组规则删除
export function ruleDel(id) {
  return request({
    url: `admin/supplier/rule/del/${id}`,
    method: 'delete'
  });
}

// 资源组列表选择
export function resourceChoice(params) {
  return request({
    url: 'admin/supplier/resource/choice',
    method: 'get',
    params
  });
}

// 资源组列表删除
export function resourceDel(id) {
  return request({
    url: `admin/supplier/resource/del/${id}`,
    method: 'delete'
  });
}

// 资源组列表选择关联的资源是否重复关联
export function resourceChoiceRepeat(params) {
  return request({
    url: 'admin/supplier/resource/choice/isRepeat',
    method: 'get',
    params
  });
}

// 未过审记录
export function supplierCheckRefuseRecord(id) {
  return request({
    url: `/admin/supplier/refuseMark/${id}`,
    method: 'get'
  });
}

// 结算撤回
export function supplierCloseAccountRecall(id) {
  return request({
    url: `/admin/supplier/closeAccountRecall/${id}`,
    method: 'put'
  });
}

// 订单选择
export function supplierOrderReselect(id) {
  return request({
    url: `admin/supplier/orderReselect/${id}`,
    method: 'put'
  });
}

// 规则下单平台
export function rulePlatform() {
  return request({
    url: 'admin/supplier/rulePlatform/list',
    method: 'get'
  });
}

// 规则下单平台引用字段
export function ruleField() {
  return request({
    url: 'admin/supplier/ruleField/list',
    method: 'get'
  });
}

// 规则新建
export function ruleAdd(data) {
  return request({
    url: 'admin/supplier/rule/add',
    method: 'post',
    data
  });
}
// 支付确认
export function supplierAffirmPay(id, data) {
  return request({
    url: `admin/supplier/affirmPay/${id}`,
    method: 'post',
    data
  });
}

// 规则编辑
export function ruleEdit(id, data) {
  return request({
    url: `admin/supplier/rule/edit/${id}`,
    method: 'put',
    data
  });
}

// 规则获取信息
export function ruleInfo(id) {
  return request({
    url: `admin/supplier/rule/info/${id}`,
    method: 'get'
  });
}

// 供应商操作日志列表
export function logList(id, params) {
  return request({
    url: `admin/supplier/log/list/${id}`,
    method: 'get',
    params
  });
}

// 供应商操作日志备注修改
export function logRemarkEdit(data) {
  return request({
    url: 'admin/supplier/log/remark',
    method: 'put',
    data
  });
}

// 结算-当前请款信息
export function currentWidthdrawInfo(id) {
  return request({
    url: `admin/supplier/currentWithdraw/info/${id}`,
    method: 'get'
  });
}
// 结算-发票列表
export function getInvoleList(params) {
  return request({
    url: 'admin/supplier/invoice',
    method: 'get',
    params
  });
}// 结算-保存发票列表
export function setInvoleList(data) {
  return request({
    url: 'admin/supplier/invoice/edit',
    method: 'put',
    data
  });
}
// 结算-审批记录列表
export function examineList(id, params) {
  return request({
    url: `admin/supplier/examine/list/${id}`,
    method: 'get',
    params
  });
}

// 结算-审批记录-付款
export function examinePay(id) {
  return request({
    url: `admin/supplier/examine/pay/${id}`,
    method: 'put'
  });
}

// 结算-审批-撤销
export function examineBack(id, data) {
  return request({
    url: `admin/supplier/examine/back/${id}`,
    method: 'put',
    data
  });
}

// 结算-审批-审批操作（通过/未过审）
export function examineOperate(id, data) {
  return request({
    url: `admin/supplier/examine/operate/${id}`,
    method: 'put',
    data
  });
}

// 结算-审批-完成
export function examineComplete(id) {
  return request({
    url: `admin/supplier/completeSettle/${id}`,
    method: 'put'
  });
}

// 结算-审批-关闭
export function examineClose(id) {
  return request({
    url: `admin/supplier/admin/supplier/close/${id}`,
    method: 'put'
  });
}

// 结算-审批-发起审批
export function launchExamine(data) {
  return request({
    url: 'admin/supplier/examine/create',
    method: 'post',
    data
  });
}

// 审批-上一步
export function examineRevoke(id, data) {
  return request({
    url: `admin/supplier/orderChange/revoke/${id}`,
    method: 'put',
    data
  });
}

// 获取供应商审批审批人记录
export function getSupplierAuditors() {
  return request({
    url: 'admin/supplier/aduitorInfo',
    method: 'get'
  });
}

// 供应商结算-删除
export function supplierListDel(id) {
  return request({
    url: `admin/supplier/del/${id}`,
    method: 'delete'
  });
}

export function getPrintInfo(params) {
  return request({
    url: 'admin/supplier/settle/print',
    method: 'get',
    params
  });
}

// 供应商结算评论列表
export function getSupplierSettlesComments(params) {
  return request({
    url: '/admin/supplierSettles/comments/list',
    method: 'get',
    params
  });
}

// 供应商结算发表评论
export function supplierSettlesCommentAdd(data) {
  return request({
    url: '/admin/supplierSettles/comments/add',
    method: 'post',
    data
  });
}

export function autoFillList(params) {
  return request({
    url: '/admin/supplier/order/quickFillIn',
    method: 'get',
    params
  });
}

export function settlementBack(data) {
  return request({
    url: '/admin/supplier/settlement/back',
    method: 'post',
    data
  });
}

export function examineCancel(data) {
  return request({
    url: '/admin/supplier/examine/cancel',
    method: 'post',
    data
  });
}
export function costBelongNums(params) {
  return request({
    url: '/admin/supplier/costBelong/list',
    method: 'get',
    params
  });
}

// 表单提交、获取审批流
export function formSubmit(data) {
  return request({
    url: '/admin/supplier/formSubmit',
    method: 'post',
    data
  });
}

// 表单提交、获取审批流
export function supplierAccountAdd(data) {
  return request({
    url: '/admin/supplier/account/add',
    method: 'post',
    data
  });
}

// 编辑结算单名称和备注
export function editCurrentWithdraw(data) {
  return request({
    url: 'admin/supplier/currentWithdraw/edit',
    method: 'put',
    data
  });
}

// 编辑收款账户说明
export function editColletMoneyList(data) {
  return request({
    url: 'admin/supplier/colletMoneyList/edit',
    method: 'put',
    data
  });
}
// 编辑分摊列表说明
export function editAllocationRemark(data) {
  return request({
    url: 'admin/supplier/allocationAmount/edit',
    method: 'put',
    data
  });
}
// 编辑标签
export function editTag(data) {
  return request({
    url: 'admin/supplier/tag/edit',
    method: 'put',
    data
  });
}
// 删除临时文件
export function deleteFile(id, params) {
  return request({
    url: `admin/supplier/tempFile/delete/${id}`,
    method: 'delete',
    params
  });
}
// 添加临时附件
export function addFile(data) {
  return request({
    url: 'admin/supplier/tempFile/add',
    method: 'post',
    data
  });
}

// 飞博供应商 - 操作日志
export function supplierLogOperation(params) {
  return request({
    url: 'admin/supplier/log',
    method: 'get',
    params
  });
}

// 供应商结算 - 邀请他人填写
export function inviteOthers(data) {
  return request({
    url: 'admin/supplier/invite',
    method: 'post',
    data
  });
}

// 付款申请协作版 - 刷新
export function refreshOrderList(params) {
  return request({
    url: 'admin/supplier/order/refresh',
    method: 'get',
    params
  });
}

// 付款申请协作版 - 填写订单
export function addSettleOrder(data) {
  return request({
    url: 'admin/supplier/addSettleOrder',
    method: 'post',
    data
  });
}

// 付款申请协作版 - 删除订单
export function deleteSettleOrder(data) {
  return request({
    url: 'admin/supplier/clearSettleOrder',
    method: 'delete',
    data
  });
}

// 供应商结算列表 - 审批单维度
export function getSupplierApprovalList(params, cancelToken) {
  return request({
    url: 'admin/supplier/approval/list',
    method: 'get',
    params: {
      notShowNoAuthTip: true,
      ...params
    },
    cancelToken
  });
}

// 供应商结算列表tab - 审批单维度
export function getSupplierApprovalTab(params) {
  return request({
    url: 'admin/supplier/approval/tab',
    method: 'get',
    params
  });
}

// 待办，账号结算获取信息进行填充
export function accountSettleInfo(params) {
  return request({
    url: 'admin/supplier/smart/submit',
    method: 'get',
    params
  });
}
// 付款申请-列表统计数据
export function getSupplierStatistics(params) {
  return request({
    url: '/admin/supplier/settle/list/statistics',
    method: 'get',
    params
  });
}

export function validateExamine(data) {
  return request({
    url: '/admin/supplier/examine/validate',
    method: 'post',
    data
  });
}

// 飞博供应商 - 地址管理 - 编辑/新增
export function editAddress(id, data) {
  return request({
    url: `/admin/supplier/address/edit/${id}`,
    method: 'put',
    data
  });
}

// 飞博供应商 - 地址管理 - 删除
export function delAddress(id, data) {
  return request({
    url: `/admin/supplier/address/delete/${id}`,
    method: 'delete',
    data
  });
}

// 飞博供应商 - 收款账户 - 编辑
export function editAccount(data) {
  return request({
    url: '/admin/supplier/account/edit',
    method: 'put',
    data
  });
}

// 飞博供应商 - 收款账户 - 删除
export function delAccount(id, data) {
  return request({
    url: `/admin/supplier/account/delete/${id}`,
    method: 'delete',
    data
  });
}

// 飞博供应商 - 账号信息 - 新增
export function resourceAssociation(id, data) {
  return request({
    url: `/admin/supplier/resource/association/${id}`,
    method: 'post',
    data
  });
}

// 飞博供应商 - 账号信息 - 删除
export function delResource(id, data) {
  return request({
    url: `/admin/supplier/resource/delete/${id}`,
    method: 'delete',
    data
  });
}

// 付款申请-撤回付款
export function withdrawPay(id) {
  return request({
    url: `admin/supplier/examine/pay/withdraw/${id}`,
    method: 'post'
  });
}

// 获取行业类别
export function getBusinessType() {
  return request({
    url: '/admin/supplier/getBusinessType',
    method: 'get'
  });
}

// 飞博供应商 - 下载记录
export function downloadRecord(data) {
  return request({
    url: '/admin/supplier/attachment/download',
    method: 'post',
    data
  });
}

/**
 * 为结算单添加成本
 */
export function supplierAddCost(data) {
  return request({
    url: '/admin/supplier/addCost',
    method: 'post',
    data
  });
}
